//
//  RootViewCell.m
//  ImageTableViewBackGround
//
//  Created by Naoki TSUTSUI on 10/02/03.
//  Copyright 2010 iphoneworld.jp. All rights reserved.
//

#import "RootViewCell.h"


@implementation RootViewCell
@synthesize height;
@synthesize titleLabel;
@synthesize useDarkBackground;

- (void)setUseDarkBackground:(BOOL)flag
{
  if (flag != useDarkBackground || !self.backgroundView) {
    useDarkBackground = flag;
    
    NSString *backgroundImagePath = [[NSBundle mainBundle] pathForResource:useDarkBackground ? @"DarkBackground" : @"LightBackground" ofType:@"png"];
    UIImage *backgroundImage = [[UIImage imageWithContentsOfFile:backgroundImagePath] stretchableImageWithLeftCapWidth:0.0 topCapHeight:1.0];
    self.backgroundView = [[[UIImageView alloc] initWithImage:backgroundImage] autorelease];
    self.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.backgroundView.frame = self.bounds;
  }
}

/*
- (void)drawRect:(CGRect)rect
{
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGGradientRef gradient;
  CGColorSpaceRef colorSpace;
  size_t num_locations = 2;
  CGFloat locations[2] = { 0.0, 1.0 };
  CGFloat components[8] = { 1.0, 1.0, 1.0, 1.0,  // Start color
  0.79, 0.79, 0.79, 1.0 }; // End color
  
  colorSpace = CGColorSpaceCreateDeviceRGB();
  gradient = CGGradientCreateWithColorComponents(colorSpace, components,
                                                 locations, num_locations);
  CGPoint startPoint = CGPointMake(self.frame.size.width/2, 0.0);
  CGPoint endPoint = CGPointMake(self.frame.size.width/2, self.frame.size.height);
  CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
}
*/

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        // Initialization code
    }
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)dealloc {
    [super dealloc];
}


@end
